/**
 * Project threadpoll
 * @author lwj
 */


#ifndef _THREADPOLL_H
#define _THREADPOLL_H
#include "TaskQueue.h"
#include "Task.h"
#include <iostream>
#include <vector>
#include <thread>
using namespace std;
class ThreadPoll {
public: 
    
/**
 * @param threadNum
 * @param queSize
 */
ThreadPoll(size_t threadNum, size_t queSize);
    
~ThreadPoll();
    
void start();
    
void stop();
    
/**
 * @param ptask
 */
void addTask(Task* ptask);
private: 
    size_t _threadNum;
    size_t _queSize;
    vector<thread> _threads;
    TaskQueue _taskQue;
    bool isExit;
    
Task* getTask();
    
void doTask();
};

void wakeup();
#endif //_THREADPOLL_H
